package org.tea.domain.entity;

import org.tea.application.common.CookieProp;

import java.util.Date;

/**
 * @author lxh
 */
public class CookiePropEntity
        implements CookieProp {

    private String name;

    private String value;

    private String domain;

    private String path;

    private boolean secure;

    private boolean httpOnly;

    private Date createTime;

    private Date lastAccessTime;

    private boolean hasExpires;

    private Date expireDate;

    @Override
    public String name() {
        return name;
    }

    @Override
    public String value() {
        return value;
    }

    @Override
    public String domain() {
        return domain;
    }

    @Override
    public String path() {
        return path;
    }

    @Override
    public boolean secure() {
        return secure;
    }

    @Override
    public boolean httpOnly() {
        return httpOnly;
    }

    @Override
    public Date createTime() {
        return createTime;
    }

    @Override
    public Date lastAccessTime() {
        return lastAccessTime;
    }

    @Override
    public boolean hasExpires() {
        return hasExpires;
    }

    @Override
    public Date expireDate() {
        return expireDate;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getDomain() {
        return domain;
    }

    public void setDomain(String domain) {
        this.domain = domain;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public boolean isSecure() {
        return secure;
    }

    public void setSecure(boolean secure) {
        this.secure = secure;
    }

    public boolean isHttpOnly() {
        return httpOnly;
    }

    public void setHttpOnly(boolean httpOnly) {
        this.httpOnly = httpOnly;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getLastAccessTime() {
        return lastAccessTime;
    }

    public void setLastAccessTime(Date lastAccessTime) {
        this.lastAccessTime = lastAccessTime;
    }

    public boolean isHasExpires() {
        return hasExpires;
    }

    public void setHasExpires(boolean hasExpires) {
        this.hasExpires = hasExpires;
    }

    public Date getExpireDate() {
        return expireDate;
    }

    public void setExpireDate(Date expireDate) {
        this.expireDate = expireDate;
    }

    public static final class Builder {
        private String name;
        private String value;
        private String domain;
        private String path;
        private boolean secure;
        private boolean httpOnly;
        private Date createTime;
        private Date lastAccessTime;
        private boolean hasExpires;
        private Date expireDate;

        private Builder() {
        }

        public static Builder builder() {
            return new Builder();
        }

        public Builder name(String name) {
            this.name = name;
            return this;
        }

        public Builder value(String value) {
            this.value = value;
            return this;
        }

        public Builder domain(String domain) {
            this.domain = domain;
            return this;
        }

        public Builder path(String path) {
            this.path = path;
            return this;
        }

        public Builder secure(boolean secure) {
            this.secure = secure;
            return this;
        }

        public Builder httpOnly(boolean httpOnly) {
            this.httpOnly = httpOnly;
            return this;
        }

        public Builder createTime(Date createTime) {
            this.createTime = createTime;
            return this;
        }

        public Builder lastAccessTime(Date lastAccessTime) {
            this.lastAccessTime = lastAccessTime;
            return this;
        }

        public Builder hasExpires(boolean hasExpires) {
            this.hasExpires = hasExpires;
            return this;
        }

        public Builder expireDate(Date expireDate) {
            this.expireDate = expireDate;
            return this;
        }

        public CookiePropEntity build() {
            CookiePropEntity cookiePropEntity = new CookiePropEntity();
            cookiePropEntity.secure = this.secure;
            cookiePropEntity.value = this.value;
            cookiePropEntity.domain = this.domain;
            cookiePropEntity.lastAccessTime = this.lastAccessTime;
            cookiePropEntity.expireDate = this.expireDate;
            cookiePropEntity.httpOnly = this.httpOnly;
            cookiePropEntity.createTime = this.createTime;
            cookiePropEntity.name = this.name;
            cookiePropEntity.path = this.path;
            cookiePropEntity.hasExpires = this.hasExpires;
            return cookiePropEntity;
        }
    }
}
